printer 2.2.1
Loading...
Searching...
No Matches
Printer Click Driver

API for configuring and manipulating Printer Click driver. More...

Topics

 Printer Device Settings
 Settings for registers of Printer Click driver.
 Printer MikroBUS Map
 MikroBUS pin mapping of Printer Click driver.

Functions

void printer_cfg_setup (printer_cfg_t *cfg)
 Printer configuration object setup function.
err_t printer_init (printer_t *ctx, printer_cfg_t *cfg)
 Printer initialization function.
err_t printer_default_cfg (printer_t *ctx)
 Printer default configuration function.
err_t printer_generic_write (printer_t *ctx, uint8_t *data_in, uint32_t len)
 Printer data writing function.
err_t printer_generic_read (printer_t *ctx, uint8_t *data_out, uint8_t len)
 Printer data reading function.
uint8_t printer_get_rts_pin (printer_t *ctx)
 Printer get RTS pin function.
err_t printer_get_status (printer_t *ctx)
 Printer get status function.
err_t printer_get_fw_info (printer_t *ctx)
 Printer get FW info function.
err_t printer_set_com_mode (printer_t *ctx, uint8_t baud_rate, uint8_t flow_control)
 Printer set com mode function.
err_t printer_set_printer_head (printer_t *ctx, uint8_t head_index)
 Printer set printer head function.
err_t printer_soft_init (printer_t *ctx)
 Printer soft init function.
err_t printer_print_lf (printer_t *ctx)
 Printer print LF function.
err_t printer_print_cr (printer_t *ctx)
 Printer print CR function.
err_t printer_print_string (printer_t *ctx, char *data_in)
 Printer print string function.
err_t printer_print_string_lf (printer_t *ctx, char *data_in)
 Printer print string function.
err_t printer_print_dots (printer_t *ctx, uint8_t num_dots)
 Printer print dots function.
err_t printer_print_lines (printer_t *ctx, uint8_t num_lines)
 Printer print lines function.
err_t printer_set_font_type (printer_t *ctx, uint8_t font_type)
 Printer set font type function.
err_t printer_set_alignment (printer_t *ctx, uint8_t align)
 Printer set alignment function.
err_t printer_set_line_spacing (printer_t *ctx, uint8_t num_dots)
 Printer set line spacing function.
err_t printer_default_line_spacing (printer_t *ctx)
 Printer default line spacing function.
err_t printer_set_horizontal_tab (printer_t *ctx, uint8_t *col_pos, uint8_t num_tabs)
 Printer set horizontal tab function.
err_t printer_horizontal_tab (printer_t *ctx)
 Printer horizontal tab function.
err_t printer_print_picture (printer_t *ctx, uint8_t *pic_buf, uint16_t h_size, uint16_t v_size)
 Printer print picture function.
err_t printer_set_left_margin (printer_t *ctx, uint8_t num_dots)
 Printer set left margin function.
err_t printer_set_right_margin (printer_t *ctx, uint8_t num_dots)
 Printer set right margin function.
err_t printer_set_abs_print_pos (printer_t *ctx, uint16_t num_dots)
 Printer set abs print pos function.
err_t printer_set_font_grayscale (printer_t *ctx, uint8_t grayscale)
 Printer set font grayscale function.
err_t printer_set_db_mode (printer_t *ctx)
 Printer set db mode function.
err_t printer_cancel_db_mode (printer_t *ctx)
 Printer cancel db mode function.
err_t printer_set_font_size (printer_t *ctx, uint8_t size)
 Printer set font size function.
err_t printer_hide_barcode_text (printer_t *ctx)
 Printer hide barcode text function.
err_t printer_show_barcode_text (printer_t *ctx)
 Printer show barcode text function.
err_t printer_set_barcode_height (printer_t *ctx, uint8_t height)
 Printer set barcode height function.
err_t printer_set_barcode_width (printer_t *ctx, uint8_t width)
 Printer set barcode width function.
err_t printer_print_barcode (printer_t *ctx, uint8_t barcode_sys, uint8_t *barcode, uint8_t barcode_len)
 Printer print barcode function.
err_t printer_clear_print_buffer (printer_t *ctx)
 Printer clear print buffer function.
err_t printer_set_printer_cb (printer_t *ctx, uint8_t callback)
 Printer set printer cb function.
err_t printer_download_nv_bitmap (printer_t *ctx, uint8_t location, uint8_t h_size, uint8_t v_size, uint8_t *bitmap)
 Printer download NV Bitmap function.
err_t printer_print_nv_bitmap (printer_t *ctx, uint8_t location)
 Printer print NV Bitmap function.
err_t printer_set_qr_size (printer_t *ctx, uint8_t size)
 Printer set QR size function.
err_t printer_set_qr_error_corr (printer_t *ctx, uint8_t corr_level)
 Printer set QR error corr function.
err_t printer_transfer_qr_code (printer_t *ctx, uint8_t *qr_code, uint16_t code_len)
 Printer transfer QR code function.
err_t printer_print_qr_code (printer_t *ctx)
 Printer print QR code function.

Detailed Description

API for configuring and manipulating Printer Click driver.

Any initialization code needed for MCU to function properly. Do not remove this line or clock might not be set correctly.

Function Documentation

◆ printer_cancel_db_mode()

err_t printer_cancel_db_mode ( printer_t * ctx)

Printer cancel db mode function.

This function cancels double-byte character mode.

Parameters
[in]ctx: Click context object. See printer_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ printer_cfg_setup()

void printer_cfg_setup ( printer_cfg_t * cfg)

Printer configuration object setup function.

This function initializes Click configuration structure to initial values.

Parameters
[out]cfg: Click configuration structure. See printer_cfg_t object definition for detailed explanation.
Returns
Nothing.
Note
The all used pins will be set to unconnected state.

◆ printer_clear_print_buffer()

err_t printer_clear_print_buffer ( printer_t * ctx)

Printer clear print buffer function.

This function clears and resets the print buffer.

Parameters
[in]ctx: Click context object. See printer_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ printer_default_cfg()

err_t printer_default_cfg ( printer_t * ctx)

Printer default configuration function.

This function executes a default configuration of Printer Click board.

Parameters
[in]ctx: Click context object. See printer_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
This function can consist any necessary configuration or setting to put device into operating mode.

◆ printer_default_line_spacing()

err_t printer_default_line_spacing ( printer_t * ctx)

Printer default line spacing function.

This function sets the line spacing to defaults.

Parameters
[in]ctx: Click context object. See printer_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ printer_download_nv_bitmap()

err_t printer_download_nv_bitmap ( printer_t * ctx,
uint8_t location,
uint8_t h_size,
uint8_t v_size,
uint8_t * bitmap )

Printer download NV Bitmap function.

This function loads bitmaps into flash memory.

Parameters
[in]ctx: Click context object. See printer_t object definition for detailed explanation.
[in]location: Bitmap location in flash from 1 to 4.
[in]h_size: Horizontal byte number.
[in]v_size: Vertical dot number.
[in]bitmap: Starting address of the bitmap buffer.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ printer_generic_read()

err_t printer_generic_read ( printer_t * ctx,
uint8_t * data_out,
uint8_t len )

Printer data reading function.

This function reads a desired number of data bytes by using UART serial interface.

Parameters
[in]ctx: Click context object. See printer_t object definition for detailed explanation.
[out]data_out: Output read data.
[in]len: Number of bytes to be read.
Returns
  • >0 - Number of data bytes read,
  • <=0 - Error/Empty Ring buffer. See #err_t definition for detailed explanation.
Note
None.

◆ printer_generic_write()

err_t printer_generic_write ( printer_t * ctx,
uint8_t * data_in,
uint32_t len )

Printer data writing function.

This function waits for a device ready flag and writes a desired number of data bytes by using UART serial interface.

Parameters
[in]ctx: Click context object. See printer_t object definition for detailed explanation.
[in]data_in: Data buffer for sending.
[in]len: Number of bytes for sending.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ printer_get_fw_info()

err_t printer_get_fw_info ( printer_t * ctx)

Printer get FW info function.

This function reads the firmware information of the printer and stores results in ctx->fw_info string buffer.

Parameters
[in]ctx: Click context object. See printer_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
Response format: 1st line: controller type 2nd line: firmware version 3rd line: firmware date 4th line: print head family index.

◆ printer_get_rts_pin()

uint8_t printer_get_rts_pin ( printer_t * ctx)

Printer get RTS pin function.

This function returns the RTS/Busy pin logic state.

Parameters
[in]ctx: Click context object. See printer_t object definition for detailed explanation.
Returns
Pin logic state.
Note
None.

◆ printer_get_status()

err_t printer_get_status ( printer_t * ctx)

Printer get status function.

This function reads the paper status and temperature of the printer and stores results in ctx->status string buffer.

Parameters
[in]ctx: Click context object. See printer_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
Response format: 1st line: 0 = No Paper, 1 = Paper OK 2nd line: xxC = temperature in Celsius.

◆ printer_hide_barcode_text()

err_t printer_hide_barcode_text ( printer_t * ctx)

Printer hide barcode text function.

This function sets a barcode text to hide.

Parameters
[in]ctx: Click context object. See printer_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ printer_horizontal_tab()

err_t printer_horizontal_tab ( printer_t * ctx)

Printer horizontal tab function.

This function moves the printing position to the next tab position in horizontal.

Parameters
[in]ctx: Click context object. See printer_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ printer_init()

err_t printer_init ( printer_t * ctx,
printer_cfg_t * cfg )

Printer initialization function.

This function initializes all necessary pins and peripherals used for this Click board.

Parameters
[out]ctx: Click context object. See printer_t object definition for detailed explanation.
[in]cfg: Click configuration structure. See printer_cfg_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ printer_print_barcode()

err_t printer_print_barcode ( printer_t * ctx,
uint8_t barcode_sys,
uint8_t * barcode,
uint8_t barcode_len )

Printer print barcode function.

This function prints a barcode in selected mode.

Parameters
[in]ctx: Click context object. See printer_t object definition for detailed explanation.
[in]barcode_sys: Barcode system, see PRINTER_BARCODE_SYS_x macro definitions.
[in]barcode: Starting address of the barcode buffer.
[in]barcode_len: Barcode buffer length.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ printer_print_cr()

err_t printer_print_cr ( printer_t * ctx)

Printer print CR function.

This function prints move to starting position.

Parameters
[in]ctx: Click context object. See printer_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ printer_print_dots()

err_t printer_print_dots ( printer_t * ctx,
uint8_t num_dots )

Printer print dots function.

This function prints and feeds paper for number of line dots.

Parameters
[in]ctx: Click context object. See printer_t object definition for detailed explanation.
[in]num_dots: Dot line number.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ printer_print_lf()

err_t printer_print_lf ( printer_t * ctx)

Printer print LF function.

This function prints new line.

Parameters
[in]ctx: Click context object. See printer_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ printer_print_lines()

err_t printer_print_lines ( printer_t * ctx,
uint8_t num_lines )

Printer print lines function.

This function prints and feeds paper for number of font lines.

Parameters
[in]ctx: Click context object. See printer_t object definition for detailed explanation.
[in]num_lines: Font lines number.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ printer_print_nv_bitmap()

err_t printer_print_nv_bitmap ( printer_t * ctx,
uint8_t location )

Printer print NV Bitmap function.

This function prints a bitmap loaded into flash memory.

Parameters
[in]ctx: Click context object. See printer_t object definition for detailed explanation.
[in]location: Bitmap location in flash from 1 to 4.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ printer_print_picture()

err_t printer_print_picture ( printer_t * ctx,
uint8_t * pic_buf,
uint16_t h_size,
uint16_t v_size )

Printer print picture function.

This function prints a raster bit image.

Parameters
[in]ctx: Click context object. See printer_t object definition for detailed explanation.
[in]pic_buf: Starting address of the image buffer.
[in]h_size: Horizontal byte number.
[in]v_size: Vertical dot number.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ printer_print_qr_code()

err_t printer_print_qr_code ( printer_t * ctx)

Printer print QR code function.

This function prints the QR code buffer.

Parameters
[in]ctx: Click context object. See printer_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ printer_print_string()

err_t printer_print_string ( printer_t * ctx,
char * data_in )

Printer print string function.

This function sends a string message to print buffer.

Parameters
[in]ctx: Click context object. See printer_t object definition for detailed explanation.
[in]data_in: String message buffer.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ printer_print_string_lf()

err_t printer_print_string_lf ( printer_t * ctx,
char * data_in )

Printer print string function.

This function prints a string message with line feed.

Parameters
[in]ctx: Click context object. See printer_t object definition for detailed explanation.
[in]data_in: String message buffer.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ printer_set_abs_print_pos()

err_t printer_set_abs_print_pos ( printer_t * ctx,
uint16_t num_dots )

Printer set abs print pos function.

This function moves the printing position for number of dots.

Parameters
[in]ctx: Click context object. See printer_t object definition for detailed explanation.
[in]num_dots: Number of dots.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ printer_set_alignment()

err_t printer_set_alignment ( printer_t * ctx,
uint8_t align )

Printer set alignment function.

This function sets the printing horizontal alignment.

Parameters
[in]ctx: Click context object. See printer_t object definition for detailed explanation.
[in]align:
  • 0 - Left,
  • 1 - Center,
  • 2 - Right.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ printer_set_barcode_height()

err_t printer_set_barcode_height ( printer_t * ctx,
uint8_t height )

Printer set barcode height function.

This function sets a barcode height level.

Parameters
[in]ctx: Click context object. See printer_t object definition for detailed explanation.
[in]height: Barcode height from 1 to 128.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ printer_set_barcode_width()

err_t printer_set_barcode_width ( printer_t * ctx,
uint8_t width )

Printer set barcode width function.

This function sets a barcode width level.

Parameters
[in]ctx: Click context object. See printer_t object definition for detailed explanation.
[in]width: Barcode width from 1 to 4.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ printer_set_com_mode()

err_t printer_set_com_mode ( printer_t * ctx,
uint8_t baud_rate,
uint8_t flow_control )

Printer set com mode function.

This function sets the device serial communication baud rate and flow control.

Parameters
[in]ctx: Click context object. See printer_t object definition for detailed explanation.
[in]baud_rate:
  • 0 - 9600,
  • 1 - 19200,
  • 2 - 38400,
  • 3 - 57600,
  • 4 - 115200.
[in]flow_control:
  • 0 - No flow control,
  • 1 - Software flow control (xon/xoff),
  • 2 - Hardware flow control.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ printer_set_db_mode()

err_t printer_set_db_mode ( printer_t * ctx)

Printer set db mode function.

This function starts double-byte character mode.

Parameters
[in]ctx: Click context object. See printer_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ printer_set_font_grayscale()

err_t printer_set_font_grayscale ( printer_t * ctx,
uint8_t grayscale )

Printer set font grayscale function.

This function sets the font grayscale level.

Parameters
[in]ctx: Click context object. See printer_t object definition for detailed explanation.
[in]grayscale: Grayscale level from 0 (min) to 8 (max).
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ printer_set_font_size()

err_t printer_set_font_size ( printer_t * ctx,
uint8_t size )

Printer set font size function.

This function sets the font size to small or large.

Parameters
[in]ctx: Click context object. See printer_t object definition for detailed explanation.
[in]size: Font size 1 - small, 2 - large.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ printer_set_font_type()

err_t printer_set_font_type ( printer_t * ctx,
uint8_t font_type )

Printer set font type function.

This function sets the printing font type.

Parameters
[in]ctx: Click context object. See printer_t object definition for detailed explanation.
[in]font_type: Font type combination, see PRINTER_FONT_TYPE_x definitions.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ printer_set_horizontal_tab()

err_t printer_set_horizontal_tab ( printer_t * ctx,
uint8_t * col_pos,
uint8_t num_tabs )

Printer set horizontal tab function.

This function sets a desired number of horizontal tabs.

Parameters
[in]ctx: Click context object. See printer_t object definition for detailed explanation.
[in]col_pos: Array of column position.
[in]num_tabs: Number of tabs / column positions.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ printer_set_left_margin()

err_t printer_set_left_margin ( printer_t * ctx,
uint8_t num_dots )

Printer set left margin function.

This function sets the left margin to number of dots.

Parameters
[in]ctx: Click context object. See printer_t object definition for detailed explanation.
[in]num_dots: Number of dots.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ printer_set_line_spacing()

err_t printer_set_line_spacing ( printer_t * ctx,
uint8_t num_dots )

Printer set line spacing function.

This function sets the line spacing for number of line dots.

Parameters
[in]ctx: Click context object. See printer_t object definition for detailed explanation.
[in]num_dots: Dot line number.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ printer_set_printer_cb()

err_t printer_set_printer_cb ( printer_t * ctx,
uint8_t callback )

Printer set printer cb function.

This function sets the printer states automatic callback.

Parameters
[in]ctx: Click context object. See printer_t object definition for detailed explanation.
[in]callback: Callback - 0 - Normal, 1 - Paper end, 2 - Overheat.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ printer_set_printer_head()

err_t printer_set_printer_head ( printer_t * ctx,
uint8_t head_index )

Printer set printer head function.

This function sets the printer head type.

Parameters
[in]ctx: Click context object. See printer_t object definition for detailed explanation.
[in]head_index:
  • 0 - MM58_FTP628MCL101 - 58mm 6stb 7.2V compatible designs
  • 1 - MM80_FTP638MCL101 - 80mm 5stb 7.2V compatible designs
  • 2 - MM58_LTP02_245_13 - 58mm 1stb line 7.2V designs
  • 3 - MM58_LTP02_245_C1 - 58mm 1stb line 4.0V designs.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ printer_set_qr_error_corr()

err_t printer_set_qr_error_corr ( printer_t * ctx,
uint8_t corr_level )

Printer set QR error corr function.

This function sets the QR code error correction level.

Parameters
[in]ctx: Click context object. See printer_t object definition for detailed explanation.
[in]corr_level:
  • 0 - 7%,
  • 1 - 15%,
  • 2 - 25%,
  • 3 - 30%.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ printer_set_qr_size()

err_t printer_set_qr_size ( printer_t * ctx,
uint8_t size )

Printer set QR size function.

This function sets the QR code size/version.

Parameters
[in]ctx: Click context object. See printer_t object definition for detailed explanation.
[in]size:
  • 0 - 21->53,
  • 1 - 57->121,
  • 2 - 125->177.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ printer_set_right_margin()

err_t printer_set_right_margin ( printer_t * ctx,
uint8_t num_dots )

Printer set right margin function.

This function sets the right margin to number of dots.

Parameters
[in]ctx: Click context object. See printer_t object definition for detailed explanation.
[in]num_dots: Number of dots.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ printer_show_barcode_text()

err_t printer_show_barcode_text ( printer_t * ctx)

Printer show barcode text function.

This function sets a barcode text to show.

Parameters
[in]ctx: Click context object. See printer_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ printer_soft_init()

err_t printer_soft_init ( printer_t * ctx)

Printer soft init function.

This function restores the printer to default configuration.

Parameters
[in]ctx: Click context object. See printer_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ printer_transfer_qr_code()

err_t printer_transfer_qr_code ( printer_t * ctx,
uint8_t * qr_code,
uint16_t code_len )

Printer transfer QR code function.

This function transfers QR code data to encode buffer.

Parameters
[in]ctx: Click context object. See printer_t object definition for detailed explanation.
[in]qr_code: Starting address of the QR code buffer.
[in]code_len: QR code length.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.